<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
      function get_primes(arr) {
   //首先把1过滤掉
   arr=arr.filter(function(x){
    return x>1
   })
   //定义遍历数组
   let f =function(a,b,c){
    return (foo>=b ||a%c[foo]>0)
   }
   //执行
   for(var foo=0;foo<arr.length;foo++){
    arr=arr.filter(f)
   }
   return arr
}

// 测试:
var
    x,
    r,
    arr = [];
for (x = 1; x < 100; x++) {
    arr.push(x);
}
r = get_primes(arr);
if (r.toString() === [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97].toString()) {
    console.log('测试通过!');
} else {
    console.log('测试失败: ' + r.toString());
}

 </script>
</head>
<body>
    
</body>
</html>